home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Disk / puriTEXT 1.1 / source / Defines.h next >
Encoding:
Text File  |  1994-03-20  |  7.2 KB  |  258 lines  |  [TEXT/KAHL]

  1. //#define DEBUG 1
  2. // Defininions for 'puriTEXT'
  3. // Copyright (C) 1994 by Mizutori Tetsuya, 94/3/9, 94/3/21
  4.  
  5. // Define macros
  6.  
  7. // general constants
  8. #define    kMoveToFront        (WindowPtr)-1L
  9. #define    kNilFilterProc        nil
  10. #define    kNilActionProc        nil
  11. #define    kScrollBarWidth        16
  12. #define    kShiftHorizontal    0
  13. #define    kShiftVertical        0
  14. #define    kShiftDItem            16384
  15. #define    kLimitDItem             8192
  16. #define    kSleep                MAXLONG
  17. #define    kVisible            true
  18. #define    kStartValue            1
  19. #define    kMinValue            1
  20. #define    kEmptyTitle            "\p"
  21. #define    kEmptyString        "\p"
  22. #define    kNilOSType            ((OSType) nil)
  23. #define    kNilAppleEvent        nil
  24. #define    kNilAppleEventID    0
  25. #define    kCheckMark            0xC3    /* option-v */
  26. #define    plain                0
  27.  
  28. #define    kDisableButton    255
  29. #define    kEnableButton    0
  30. #define    kGestaltMask    1L
  31.  
  32. // special parameters
  33. #define    kNilRefCon        0L
  34. #define    kMyRefCon        10098L /* a random unique number */
  35. #define    kNormalMode        0
  36. #define    kPrefMode        1
  37. #define    kMaxCreators    16
  38.  
  39. #define    kScrollStep1    1
  40. #define    kScrollStep2    4
  41.  
  42. // error messages in 'STR#'
  43. #define    kErrCode        (128L << 16)
  44. #define    kErrSetEOF        kErrCode+1
  45. #define    kErrMaxCreators    kErrCode+2
  46. #define    kMsgSurePurify    kErrCode+3
  47. #define    kErrFileSystem    kErrCode+4
  48. #define    kErrAppleEvent    kErrCode+5
  49.  
  50. // labels of puriTEXT in 'STR#'
  51. #define    kLabel            (129L << 16)
  52. #define    kLabelHelp        kLabel+1
  53. #define    kLabelPref        kLabel+2
  54. #define    kLabelFont        kLabel+3
  55. #define    kLabelCheck        kLabel+4
  56. #define    kLabelDoc        kLabel+5
  57. #define    kLabelSaveAs    kLabel+6
  58.  
  59. // resource IDs
  60. #define    kAlertID        1000
  61. #define    kWindowID        128
  62. #define    kDialogID        128
  63. #define    kAboutID        129
  64. #define    kNoteAlertID    130
  65. #define    kCautionAlertID    131
  66. #define    kMenuBarID        128
  67. #define    kMenuID            128
  68. #define    kTextID            128
  69. #define    kPrefType        'PREF'
  70. #define    kPrefID            128
  71. #define    mApple            kMenuID+0
  72. #define    mFile            kMenuID+1
  73. #define    mEdit            kMenuID+2
  74. #define    mCreator        kMenuID+3
  75. #define    mExclude        kMenuID+4
  76.  
  77. // item number in menus
  78. // Apple Menu
  79. #define    iAbout            1
  80. #define    iDeskAcc        3
  81. // File Menu
  82. #define    iNew            1
  83. #define    iOpen            2
  84. #define    iClose            4
  85. #define    iSave            5
  86. #define    iSaveAs            6
  87. #define    iRevert            7
  88. #define    iPageSetup        9
  89. #define    iPrint            10
  90. #define    iPreferences    12
  91. #define    iQuit            14
  92. // Edit Menu
  93. #define    iUndo            1
  94. #define    iCut            3
  95. #define    iCopy            4
  96. #define    iPaste            5
  97. #define    iClear            6
  98. #define    iDuplicate        8
  99. #define    iSelectAll        9
  100. // Creators popup menu
  101. #define    ipcAdd            1
  102. #define    ipcAppend        2
  103. #define    ipcRemove        3
  104. #define    ipcFirst        5
  105. // Exclude popup menu
  106. #define    ipeAdd            1
  107. #define    ipeAppend        2
  108. #define    ipeRemove        3
  109. #define    ipeEnable        4
  110. #define    ipeDisable        5
  111. #define    ipeFirst        7
  112.  
  113. // items in the main dialog
  114. #define    iUserItem        3
  115. #define    iTitle            4
  116. #define    iIcon            5
  117. #define    iCopyright        6
  118. #define    iVersion        7
  119. #define    iDummy            8
  120. #define    iPref            9
  121. #define    iCBCreator        10
  122. #define    iCBModDate        11
  123. #define    iCBBigRF        12
  124. #define    iCBExclude        13
  125. #define    iTextKB            19
  126. #define    iTBCreator        14
  127. #define    iTBBigRF        15
  128. #define    iTBExclude        16
  129. #define    iSWCreator        17
  130. #define    iSWExclude        18
  131. #define    iPopupCreator    20
  132. #define    iPopupExclude    21
  133.  
  134.  
  135. // datablock structures
  136. typedef struct {
  137.     Rect    rect;        // Window position
  138.     Boolean    check[4];    // Status of checkBox[0..3]
  139.     OSType    creator;    // Creator, eg. 'ttxt'
  140.     OSType    exclude;    // Creator, eg. 'MzpT'
  141.     long    sizeRF;        // Alert condition
  142.     long    flag;        // Enable/Disable flags for Exludes[]
  143.     OSType    creators[kMaxCreators];
  144.     OSType    excludes[kMaxCreators];
  145. }    PrefDataRecord, *PrefDataPtr;
  146.  
  147.  
  148. typedef    struct {
  149.     DialogRecord    dialog;
  150.     CursPtr            iBeam;
  151.     RgnHandle        iBeamRgn;
  152.     short            mode;
  153.     short            userItem;
  154.     ControlHandle    userCntl;
  155.     TEHandle        userTE;
  156.     short            **posHndl;
  157.     PrefDataRecord    pref;
  158. } myWindowRecord, myDialogRecord;
  159.  
  160. typedef myWindowRecord *myWindowPeek, *myWindowPtr;
  161. typedef myDialogRecord *myDialogPeek, *myDialogPtr;
  162.  
  163.  
  164. // Definition for macro functions
  165. #define    my(window,field)    (((myWindowPeek)window)->field)
  166.  
  167. #define ShiftValue(window,curVal,newVal) \
  168.     ( (*my(window,posHndl))[newVal-kMinValue] \
  169.     - (*my(window,posHndl))[curVal-kMinValue] )
  170. //    ( newVal - curVal )
  171.  
  172. #define TypToString(t,s)    { s[0]=4; BlockMove(&t,&s[1],4); }
  173. #define StringToTyp(s,t)    { BlockMove(&s[1],t,4); }
  174. // !!! CAUSION !!!  Usage: StringToTyp(text,&type);
  175.  
  176. //#define TopLeft( r )        (* (Point *) &(r).top)
  177. //#define BottomRight( r )    (* (Point *) &(r).bottom)
  178.  
  179. pascal OSErr SetDialogDefaultItem( DialogPtr dialog, short item ) =
  180.             { 0x303C, 0x0304, 0xAA68 };
  181. pascal OSErr SetDialogCancelItem( DialogPtr dialog, short item ) =
  182.             { 0x303C, 0x0305, 0xAA68 };
  183. pascal OSErr SetDialogTracksCursor( DialogPtr dialog, Boolean tracks ) =
  184.             { 0x303C, 0x0306, 0xAA68 };
  185.  
  186.  
  187. // Prototypes (generals.c)
  188. /***** Do Error Messages *****/
  189. void ErrorMessage( OSErr err, StringPtr string, Boolean fatal );
  190. void StopMessage( long errCode, StringPtr str1, StringPtr str2,long value );
  191. void NoteMessage( long errCode, StringPtr str1, StringPtr str2,long value );
  192. Boolean CautionMessage( long errCode, StringPtr str1, StringPtr str2,long value );
  193. void SetupParam( long errCode, StringPtr str1, StringPtr str2, long value );
  194. /***** Gestalt check *****/
  195. void GestaltCheck( OSType gestaltCode );
  196. /***** Get Text from resource *****/
  197. StringPtr GetIndText( long code, StringPtr text );
  198. /***** Pstring *****/
  199. //void TypToString( OSType type, StringPtr str );
  200. //void StringToTyp( StringPtr str, OSType *type );
  201. StringPtr Pstrcpy( StringPtr dst, const StringPtr src );
  202. StringPtr Pstrcat( StringPtr dst, const StringPtr src );
  203. short Pstrcmp( const StringPtr dst, const StringPtr src );
  204. short Pstrncmp( const StringPtr dst, const StringPtr src, Size k );
  205. /***** Read & Write resource *****/
  206. Boolean LoadRsrcPREF( PrefDataPtr dataBlock );
  207. void SaveRsrcPREF( PrefDataPtr dataBlock );
  208. /***** Window operations *****/
  209. void GetWindowRect( WindowPtr window, Rect *rect );
  210. /***** Dialog operations *****/
  211. Handle IGetTxtHand( DialogPtr dialog, short item );
  212. ControlHandle IGetCtlHand( DialogPtr dialog, short item );
  213. /***** Standard File Get & Put *****/
  214. Boolean GetFileDialog( short numTypes, SFTypeList typeList, FSSpec *theFSSpec );
  215. Boolean PutFileDialog( StringPtr prompt, Boolean *replacing, FSSpec *theFSSpec );
  216. /***** Menu Operation *****/
  217. short GetMenuInd( MenuHandle menu, StringPtr text );
  218. short TrackPopupMenu( ControlHandle theCntl );
  219.  
  220. // Prototypes (modelessDialog.c)
  221. Boolean ModelessDialog( DialogPtr dialog, EventRecord *event, short *item );
  222. Boolean IsDialogEdit( DialogPtr dialog, EventRecord *event );
  223. pascal Boolean MyDialogFilter( DialogPtr dialog, EventRecord *event, short *item );
  224.  
  225. // Prototypes (scrollTE.c)
  226. void SetupText( WindowPtr window, short textID, Rect *rect, TEHandle *teHandle );
  227. short SetupLinePos( WindowPtr window, TEHandle teHndl, Handle *posHndl );
  228. void TEScrollProc( WindowPtr window, Point thePoint );
  229. pascal void myScrollProc( ControlHandle theControl, short thePart );
  230. void SetControl( ControlHandle theControl, short *shift );
  231.  
  232. // Prototypes (dialogList.c)
  233. void listDialog( DialogPtr dialog );
  234.  
  235. // Prototypes (errorCode.c)
  236. StringPtr ErrFS( OSErr errCode );
  237. StringPtr ErrAE( OSErr errCode );
  238.  
  239.  
  240. #ifdef DEBUG
  241. /***** DEBUG messages *****/
  242. char * DBScrollPart( short thePart );
  243. char * DBEventWhat( short what );
  244. char * DBosEvent( long message );
  245. char * DBMouseDown( short thePart );
  246. char * DBFileMenu( short item );
  247. char * DBEditMenu( short item );
  248. char * DBDITLType( short itemType );
  249. char * DBAppleEventClass( OSType item );
  250. #endif DEBUG
  251.  
  252. #ifdef DEBUG
  253. #include <stdio.h>
  254. #include <console.h>
  255. #endif DEBUG
  256.  
  257. // end of definitions
  258.